package com.servlet;

import com.dao.imp.AddParentType;
import com.dao.imp.FindAllType;
import com.entity.ParentType;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.lang.reflect.ParameterizedType;

/**
 * @author Mathison
 * @Title: ${NAME}
 * @Package: ${PACKAGE_NAME}
 * @Description: TODO
 * @date 2021/11/22 22:13
 **/

@WebServlet(name = "AddParentTypeServlet", value = "/AddParentTypeServlet")
public class AddParentTypeServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String categoryName = request.getParameter("categoryName");
        FindAllType findAllType = new FindAllType();
        System.out.println(categoryName);
//        ParentType parentType =  findAllType.getParentType().get(findAllType.getParentType().size()-1);
        String sql = "INSERT INTO parenttype (parent_typeId, parent_type) VALUES (DEFAULT,\'" +
                categoryName +
                "\')";
        System.out.println(sql);
        AddParentType addParentType = new AddParentType();
        addParentType.addGoodType(sql);
    }
}
